/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Requests.MachineManagement.Components;

import Utilities.Functions;

/**
 * This class represents the medium mounting/unmounting settings of a virtual machine.
 *
 * @author Angel Sanadinov
 */
public class MediumMountSettings extends MachineManagementComponent
{
    private String controllerName;  //the name of the controller
    private int controllerPort;     //the controller port
    private int controllerSlot;     //the controller slot
    private String mediumId;        //the medium id
    private boolean forceMount;     //should the mounting be forced

    /**
     * Constructs a medium mounting/unmounting settings object with the specified data. <br><br>
     *
     * A medium should be mounted on a controller that already has a device capable
     * of accepting the mounting.
     *
     * @param controllerName the name of the controller which has the device
     * @param controllerPort the device's controller port
     * @param controllerSlot the device's controller slot
     * @param mediumId the id of the medium that is to be mounted
     * @param forceMount force the mounting of a locked medium
     */
    public MediumMountSettings(String controllerName, int controllerPort, int controllerSlot,
                               String mediumId, boolean forceMount)
    {
        this.controllerName = controllerName;
        this.controllerPort = controllerPort;
        this.controllerSlot = controllerSlot;
        this.mediumId = mediumId;
        this.forceMount = forceMount;
    }

    /**
     * Retrieves the name of the controller that has the device to which the
     * medium is mounted.
     *
     * @return the controller name
     */
    public String getControllerName()
    {
        return controllerName;
    }

    /**
     * Retrieves the device's controller port.
     *
     * @return the controller port
     */
    public int getControllerPort()
    {
        return controllerPort;
    }

    /**
     * Retrieves the device's controller slot.
     *
     * @return the controller slot
     */
    public int getControllerSlot()
    {
        return controllerSlot;
    }

    /**
     * Retrieves the medium id.
     *
     * @return the medium id
     */
    public String getMediumId()
    {
        return mediumId;
    }

    /**
     * Retrieves the force mount state.
     *
     * @return <code>true</code> if mounting/unmounting should be forced or
     *         <code>false</code> otherwise
     */
    public boolean getForceMount()
    {
        return forceMount;
    }

    @Override
    public boolean isValid()
    {
        if(controllerName != null && Functions.isControllerPortValid(controllerPort)
                && Functions.isControllerSlotValid(controllerSlot)
                && (mediumId == null || Functions.isUUIDValid(mediumId)))
            return true;
        else
            return false;
    }
}
